package main

import (
	"fmt"
	"github.com/google/gopacket"
	"github.com/google/gopacket/layers"
	"github.com/google/gopacket/pfring"
)

func main() {
	ring, err := pfring.NewRing("eno3", 65535, pfring.FlagPromisc)
	if err != nil {
		panic(err)
	}
	err = ring.SetBPFFilter("tcp and dst host ")
	if err != nil { // optional
		panic(err)
	}
	err = ring.Enable()
	if err != nil { // Must do this!, or you get no packets!
		panic(err)
	}
	err = ring.SetCluster(1, pfring.ClusterPerFlow)
	err = ring.SetSocketMode(pfring.ReadOnly)
	if err != nil {
		panic(err)
		return
	}
	defer ring.Close()
	source := gopacket.NewPacketSource(ring, layers.LinkTypeEthernet)
	for packet := range source.Packets() {
		fmt.Println(packet)
	}
}
